#include<iostream>
#include<unordered_map>
#include<algorithm>
using namespace std;

class Solution {
public:
    vector<vector<string>> groupAnagrams(vector<string>& strs) {
        vector<vector<string>>ret;
        unordered_map<string, vector<string>>hash;
        for (int i = 0; i < strs.size(); i++)
        {
            string str = strs[i];
            sort(str.begin(), str.end());
            hash[str].push_back(strs[i]);
        }
        for (auto e : hash)
        {
            ret.push_back(e.second);
        }
        return ret;
    }
};